﻿<%@ CODEPAGE=65001 %>
<%
'///////////////////////////////////////////////////////////////////////////////
'// 插件应用:    Z-Blog 2.0 其它版本未知
'// 插件制作:    狼的旋律(http://www.wilf.cn) / zsx(http://www.zsxsoft.com)
'// 备    注:    图片展示页面
'// 最后修改:
'// 最后版本:
'///////////////////////////////////////////////////////////////////////////////
%>
<% Option Explicit %>
<% 'On Error Resume Next %>
<% Response.Charset="UTF-8" %>
<% Response.Buffer=True %>
<!-- #include file="../../c_option.asp" -->
<!-- #include file="../../../zb_system/function/c_function.asp" -->
<!-- #include file="../../../zb_system/function/c_system_lib.asp" -->
<!-- #include file="../../../zb_system/function/c_system_base.asp" -->
<!-- #include file="../../../zb_system/function/c_system_plugin.asp" -->
<!-- #include file="../../plugin/p_config.asp" -->
<%
Call System_Initialize()
Call WindsPhoto_Initialize()

If CheckpluginState("windsphoto") = False Then Call ShowError(48)

Dim id,objRs,sql,temprs,typename,ps,pss,name,typeid,url,time,jj,viewnums
If IsNumeric(Request.QueryString("id")) = False Then
    ShowError(3)
Else
    id = CInt(Request.QueryString("id"))
End If

Set objRs = Server.CreateObject("ADODB.Recordset")
sql = "select * from windsphoto_desktop where id="&id
objRs.Open sql, objConn, 1, 3
If objRs.EOF Or objRs.bof Then ShowError(3)
name = objRs("name")
If name="" Then name="未命名"
typeid = objRs("zhuanti")
url = objRs("url")
time = objRs("itime")
If time Then
	time = Replace(time,"/","-")
Else
	time = ""
End If
jj = objRs("jj")
viewnums = objRs("viewnums")

Set temprs = objConn.Execute("select name,pass from windsphoto_zhuanti where id="&typeid)
typename = temprs(0)
ps = temprs(1)
Set temprs = Nothing
pss = Request.cookies("WindsPhoto"&typeid)
If Len(ps)<>0 Then
    If pss<>ps Then
        Response.Redirect "album.asp?typeid="&typeid
    End If
End If

If viewnums="" or IsNULL(viewnums)=True Then
    objRs("viewnums") = "1"
Else
    If BlogUser.Level>2 Then objRs("viewnums") = viewnums+1
End If
objRs.update

Dim GetPhotoInfo
GetPhotoInfo = GetPhotoInfo & "<li>浏览次数: "&viewnums&"</li>" & VBCRLF
If time<>"" Then GetPhotoInfo = GetPhotoInfo & "<li>上传时间: "&time&"</li>" & VBCRLF

Dim preid,preurl,nextid,nexturl,preloadpic
Set temprs = objconn.Execute("select top 1 ID from windsphoto_desktop where zhuanti="&typeid&" and ID>"&id&" order by id asc")
If Not temprs.bof Then
    preid = temprs("id")
	preurl = "display.asp?id="&preid&"#image"
Else
    preurl = "#"
End If
Set temprs = Nothing
Set temprs = objconn.Execute("select top 1 ID,url from windsphoto_desktop where zhuanti="&typeid&" and ID<"&id&" order by id desc")
If Not temprs.bof Then
    nextid = temprs("id")
	nexturl = "display.asp?id="&nextid&"#image"
	preloadpic = temprs("url")
	If Left(preloadpic,4)<>"http" Then preloadpic = WP_SUB_DOMAIN & preloadpic
Else
    nexturl = "#"
End If
Set temprs = Nothing

Dim Getdisplay
GetDisplay = GetDisplay & VBCRLF & "<script type=""text/javascript"">" & VBCRLF
GetDisplay = GetDisplay & "document.onkeydown=ToPage" & VBCRLF
GetDisplay = GetDisplay & "var prevpage="""&preurl&"""" & VBCRLF
GetDisplay = GetDisplay & "var nextpage="""&nexturl&"""" & VBCRLF
If preloadpic<>"" Then GetDisplay = GetDisplay & "$.preload( '"&preloadpic&"');" & VBCRLF
GetDisplay = GetDisplay & "</script>" & VBCRLF
GetDisplay = GetDisplay & "<div id=""image"" class=""wp_photo_toolbar""><span class=""ll""><img src=""images/view.gif"" align=""absmiddle""><a href="""&url&""" title="""&name&""">查看原图</a></span><a href="""&preurl&""" title=""用方向键←可以向前翻页"">上一张</a> / <a href="""&nexturl&""" title=""用方向键→可以向后翻页"">下一张</a><span class=""rr"">&gt; <a href=""album.asp?typeid="&typeid&""" title=""返回相册"">返回相册</a></span></div>" & VBCRLF
GetDisplay = GetDisplay & "<div class=""wp_photo_show""><a href="""&nexturl&""" title=""点击查看下一张""><img src="""&url&""" alt="""&name&""" class=""wp_list"" /></a>" & VBCRLF
GetDisplay = GetDisplay & "</div>" & VBCRLF
If jj<>"" Then GetDisplay = GetDisplay & "<div class=""wp_photo_intro"">" &jj& "</div>" & VBCRLF

objRs.Close
Set objRs = Nothing
%>

<%
Dim objArticle
Set objArticle = New TArticle
objArticle.FType=ZC_POST_TYPE_PAGE
If GetTemplate("TEMPLATE_WP_DISPLAY")<>empty Then objArticle.template = "WP_DISPLAY"
'objArticle.Title = name &"-"& typename &"-"& WP_ALBUM_NAME
objArticle.Title = name
objArticle.Content=GetDisplay
If objArticle.Export(ZC_DISPLAY_MODE_SYSTEMPAGE) Then
	objArticle.Build
    Dim Html,AddedHtml
    Html = objArticle.html
	AddedHtml="<link rel=""alternate"" type=""application/rss+xml"" href="""& WP_SUB_DOMAIN &"rss.asp?id="&typeid&""" title=""订阅我的相册"" />" & vbCrLf
	AddedHtml = AddedHtml & "<link rel=""stylesheet"" href="""& WP_SUB_DOMAIN &"images/windsphoto.css"" type=""text/css"" media=""screen"" />" & VBCRLF
    AddedHtml = AddedHtml & "<script type=""text/javascript"" src="""& WP_SUB_DOMAIN &"script/windsphoto.js""></script>" & VBCRLF
	AddedHtml = AddedHtml & "<style type=""text/css"">img.wp_top,img.wp_small img{max-width:"& WP_SMALL_WIDTH &"px;max-height:"& WP_SMALL_HEIGHT &"px;}img.wp_list{max-width:"& WP_LIST_WIDTH &"px;}</style>" & VBCRLF & "</head>"
	Html = Replace(Html, "</head>", AddedHtml)
	Html = Replace(Html, "<#WP_PHOTOINFO#>", GetPhotoInfo)
    Html = Replace(Html, ">Powered By", ">Powered By <a href=""http://www.windsphoto.com"" target=""_blank"" title=""WindsPhoto官方网站"">WindsPhoto</a> &amp;")
    Call ClearGlobeCache
    Call LoadGlobeCache
    Response.Write Html
End If
Set objArticle = Nothing
%>

<%
Call System_Terminate()

If Err.Number<>0 then
	Call ShowError(0)
End If
%>